﻿<div>
    <div style="margin-bottom:20px; margin-left:10px;" class = "pagination">
            Found Users: 
        <span style="color:blue">@ViewBag.UsersCount</span>
        <span style="margin-left:50px;">Number of User Online: <span style="color:green;">@ViewBag.numberOfUsersOnline</span></span>
        <span style="margin-left:440px;" class = "pagination">
@if(ViewBag.itemOnPage == 10 )
{
                @Ajax.ActionLink("25 item on page", "UserTable", new { orderUsersBy = ViewBag.NameSortParm ,itemOnPage = 25,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox}, new AjaxOptions{UpdateTargetId = "table",LoadingElementId = "loading",LoadingElementDuration = 1000})
}
            else{
                    @Ajax.ActionLink("10 item on page", "UserTable", new { orderUsersBy = ViewBag.NameSortParm ,itemOnPage = 10,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox }, new AjaxOptions{UpdateTargetId = "table",LoadingElementId = "loading",LoadingElementDuration = 1000})
    
}
        </span>
    </div>

    <div>

    <table class="rounded-corner">
        <thead>
        <tr>
            <th  class="rounded-company"></th>
            <th>@Ajax.ActionLink("User Name","UserTable",new { orderUsersBy = ViewBag.NameSortParm ,itemOnPage = ViewBag.itemOnPage,page = ViewBag.currentPage ,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox},new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("First Name", "UserTable", new { orderUsersBy = ViewBag.SortByFirstName,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage, searchString = ViewBag.searchString, listSelectField = ViewBag.listSelectField, listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox }, new AjaxOptions { UpdateTargetId = "table" })</th>
            <th>@Ajax.ActionLink("Last Name","UserTable",new { orderUsersBy = ViewBag.SortByLastName,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Role", "UserTable", new { orderUsersBy = ViewBag.SortByRole,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Email","UserTable",new { orderUsersBy =  ViewBag.SortByEmail,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th>@Ajax.ActionLink("Region","UserTable",new { orderUsersBy = ViewBag.SortByRegion ,itemOnPage = ViewBag.itemOnPage, page = ViewBag.currentPage,searchString = ViewBag.searchString,listSelectField = ViewBag.listSelectField,listSelectCondition = ViewBag.listSelectCondition,statusCheckBox = ViewBag.CheckBox },new AjaxOptions{ UpdateTargetId="table"})</th>
            <th class="rounded-q4">Operate</th>
        </tr>
        </thead>
        <tbody>
    @foreach (var c in ViewBag.Users)
    {
        <tr>
            <td></td>
            <td>@c.LoginName</td>
            <td>@c.FirstName</td>
            <td>@c.LastName</td>
            <td>@c.Role.Name</td>
            <td>@c.Email</td>
            <td>@c.Region</td>
           
            <td><a href="@Url.Action("Edit", "Administration", new { @userLogin = c.LoginName  })"><img src="../../Content/images/user_edit.png" alt="Edit" title="Edit" border="0" /></a>
            <a href="@Url.Action("Delete", "Administration", new { @userLogin = c.LoginName  })"><img src="../../Content/images/trash.png" alt="Delete" title="Delete" border="0" /></a>
            <a href="@Url.Action("Dublicate", "Administration", new { @userLogin = c.LoginName  })"><img src="../../Content/images/dublicate.png" alt="Dublicate" title="Dublicate" border="0" /></a></td>
        </tr>
               
    }
    @if (ViewBag.Users.Count != ViewBag.itemOnPage)
    {
        for (int i = 0; i <= ViewBag.itemOnPage - ViewBag.Users.Count; i++)
        {
            <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
        }
    }
    </tbody>
    </table>
      </div>
     <span id="numberOfPage">Page #: @ViewBag.currentPage from @ViewBag.lastPage</span>
        <div class="pagination">
           

         @if (ViewBag.currentPage == 1)
         {
             <span class="disabled">first</span>
             <span class="disabled">< prev</span>
         }
         else
         
         {
             <span>

                 @Ajax.ActionLink("first", "UserTable", new { 
                
                  itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderUsersBy = ViewBag.currentSortUserBy, 
                  page = 1,statusCheckBox = ViewBag.CheckBox 
        
             },new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                        LoadingElementDuration=1000})

             </span>
             
             <span>
                 @Ajax.ActionLink("< prev", "UserTable", new { 
                itemOnPage = ViewBag.itemOnPage,
                  searchString = ViewBag.searchString, 
                  listSelectField = ViewBag.listSelectField, 
                  listSelectCondition = ViewBag.listSelectCondition, 
                  orderUsersBy = ViewBag.currentSortUserBy, 
                  page = ViewBag.currentPage - 1,
                  statusCheckBox = ViewBag.CheckBox 
                  
              }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                          LoadingElementDuration=1000})

             </span>
             
             
         }
         @if (ViewBag.UsersCount <= ViewBag.currentPage * ViewBag.itemOnPage)
         {
             <span class="disabled">next ></span>
             <span class="disabled">last</span>
         }
            else
            {
                 <span>

                     @Ajax.ActionLink("next >", "UserTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderUsersBy = ViewBag.currentSortUserBy, 
                      page = ViewBag.currentPage + 1,
                      statusCheckBox = ViewBag.CheckBox 
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
                 <span>
                     @Ajax.ActionLink("last", "UserTable", new {
                        itemOnPage = ViewBag.itemOnPage,
                      searchString =ViewBag.searchString, 
                      listSelectField =ViewBag.listSelectField, 
                      listSelectCondition = ViewBag.listSelectCondition, 
                      orderUsersBy = ViewBag.currentSortUserBy, 
                      page = ViewBag.lastPage,
                      statusCheckBox = ViewBag.CheckBox
              
                  }, new AjaxOptions{ UpdateTargetId="table", LoadingElementId="loading", 
                                                              LoadingElementDuration=1000})

                 </span>
         }
   </div>
    
</div>